package com.gandong8.trace.tool.core;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class CacheAspect {
    @Around("execution( * com.gandong8.trace.tool.service.CacheService.*(..))")
    public Object handleRedis(ProceedingJoinPoint joinPoint) throws Throwable {
        long startTime = SystemClock.now();
        Object result = joinPoint.proceed();
        long cost = SystemClock.now() - startTime;
        log.warn("redisAspect:{},{},{}", cost, joinPoint.getSignature().getName(), joinPoint.getArgs());
        return result;
    }

}
